<!--
* description: 网点备件销售-网点销售开票信息查询
* author: hzm
* createdDate: 2021-3-5
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="dynamicApiConfigs"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-init-table="true"
      :dynamic-is-fix-choose="false"
      :dynamic-is-fix-index="false"
      :dynamic-is-show-more-btn="true"
      :dynamic-api-style="'restful'"
    />
  </div>
</template>

<script>
import { formMixins } from "@/components/mixins/formMixins";
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import OneTableTemplate from "@/components/templates/oneTable";
import { orgApis } from "@/api/paSparePartsManagement"
import { exportExcel } from '@/utils/getTimeString.js'

export default {
  name: "salesInformationQuiry",
  components: {
    OneTableTemplate,
  },
  mixins: [oneTableWithViewTemplateMixins, formMixins],
  data() {
    return {
      dynamicApiConfigs: orgApis.getSparePartsManagement,
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
              {
                prop: "saleOrderDCode",
                label: "销售单号",
                align: "center",
              },
              {
                prop: "customerTypeCn",
                label: "客户性质",
                align: "center",
              },
              {
                prop: "saleTypeCn",
                label: "销售类型",
                align: "center",
              },
              {
                prop: "customerName",
                label: "客户名称",
                align: "center",
              },
              {
                prop: "partNo",
                label: "备件编号",
                align: "center",
              },
              {
                prop: "partName",
                label: "备件名称",
                align: "center",
              },
              {
                prop: "salePrice",
                label: "销售价格",
                align: "center",
              },
              {
                prop: "saleQty",
                label: "销售数量",
                align: "center",
              },
              {
                prop: "saleAmount",
                label: "销售金额",
                align: "center",
              },
              {
                prop: "invoiceStatusCn",
                label: "开票状态",
                align: "center",
              },
              {
                prop: "invoiceDate",
                label: "开票时间",
                align: "center",
              },
              {
                prop: "invoiceNo",
                label: "发票号",
                align: "center",
              },
              {
                prop: "createdDate",
                label: "制单时间",
                align: "center",
              }
            ],
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
              .tableComponents
          : [
              // 库存状态
              {
                compKey: "compKey1",
                labelName: "网点编码：",
                codeField: "moveState",
                lookuptype: "VE0212",
                component: () => import("@/components/ve/multipleSearchInput"),
                type: "inputText",
                isMust: true,
                disabled: false,
                dataToObject: {
                  oFields: 'dlrCode,dlrShortName',
                  // 控制弹窗页面 搜索 网格 元素
                  tableComponents: [
                    {
                      compKey: "compKey1",
                      labelName: "网点编码：",
                      codeField: "dlrCode",
                      component: () => import("@/components/org/commonInput"),
                      type: "inputText",
                      isMust: true,
                      span: 8,
                    },
                    {
                      compKey: "compKey2",
                      labelName: "网点名称：",
                      codeField: "dlrShortName",
                      component: () => import("@/components/org/commonInput"),
                      type: "inputText",
                      isMust: true,
                      span: 8,
                    },
                  ],
                  tableCols: [
                    {
                      prop: "dlrCode",
                      label: "网点编码",
                    },
                    {
                      prop: "dlrShortName",
                      label: "网点名称",
                    },
                  ],
                  formField: {
                    dlrShortName: '',
                    dlrCode: ''
                  },
                  returnField: {
                    prop: "dlrCode",
                    label: "网点编码",
                  },
                  api: orgApis.queryOrgDlrCodes
                },
                span: 6,
              },
              // 入库仓库
              {
                compKey: "compKey4",
                labelName: "网点名称：",
                codeField: "carStockHouseId",
                component: () => import("@/components/org/commonInput"),
                oFields: "AsId,AsText",
                type: "inputText",
                isMust: true,
                span: 6,
                disabled: false
              },
               // 审核状态
              {
                compKey: "compKey5",
                labelName: "销售单号：",
                codeField: "saleOrderDCode",
                component: () => import("@/components/org/commonInput"),
                oFields: "AsId,AsText",
                type: "inputText",
                isMust: true,
                span: 6,
              },
              // 车辆状态
              {
                compKey: "compKey6",
                labelName: "客户性质：",
                codeField: "customerType",
                component: () => import("@/components/org/userSeleapiConfig"),
                oFields: "statusId,statusText",
                type: "inputText",
                options: [
                  { statusId: '1', statusText: '直营店' },
                  { statusId: '2', statusText: '授权店' },
                  { statusId: '0', statusText: '普通客户' },
                ],
                isMust: true,
                span: 6,
              },
              {
                compKey: "compKey7",
                labelName: "客户名称：",
                codeField: "customerName",
                lookuptype: "VE0212",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: false,
                span: 6,
              },
              {
                compKey: "compKey8",
                labelName: "制单日期：",
                // codeField: "createdDate",
                codeField: "beginDate,endDate",
                component: () => import("@/components/org/datePicker/andtDatePicker"),
                oFields: "AsId,AsText",
                type: "inputText",
                isMust: false,
                span: 6,
              },
              {
                compKey: "compKey9",
                labelName: "销售类型：",
                codeField: "saleType",
                lookuptype: "VE0212",
                component: () => import("@/components/org/userSeleapiConfig"),
                type: "inputText",
                oFields: "statusId,statusText",
                options: [
                  { statusId: '0', statusText: '呆滞件销售' },
                  { statusId: '2', statusText: '常规销售' },
                ],
                isMust: false,
                span: 6,
              },
              {
                compKey: "compKey10",
                labelName: "开票状态：",
                codeField: "invoiceStatus",
                lookuptype: "VE0212",
                component: () => import("@/components/org/userSeleapiConfig"),
                type: "inputText",
                oFields: "statusId,statusText",
                options: [
                  { statusId: '1', statusText: '已开票' },
                  { statusId: '0', statusText: '未开票' }
                ],
                isMust: false,
                span: 6,
              },
            ],
      tableButtons: [
        {
          conmpKey: "btenKey3",
          type: "primary",
          size: "small",
          text: "查询",
          name: "search",
          clickEvent: () => this.queryTable(1),
          position: "right",
        },
        {
          conmpKey: "btenKey1",
          type: "",
          size: "small",
          text: "导出",
          name: "save",
          clickEvent: () => this.exportExcel1(),
          position: "right",
        },
        {
          conmpKey: "btenKey2",
          type: "",
          size: "small",
          text: "重置",
          name: "reset",
          clickEvent: () => this.reset1(),
          position: "right",
        },
      ],
      formField: this.$utils.getFormField(this, {
        moveState: "",
        carStockHouseId: "",
        saleOrderDCode: "",
        customerType: "",
        customerName: "",
        createdDate: "",
        saleType: "",
        invoiceStatus: "",
        beginDate: "",
        endDate: "",
      }),
    };
  },
  methods: {
    reset1(){
      if(this.$store.getters.orgInfo.DLR_ID === "HOST"){//总部
        this.formField.moveState = ''
        this.formField.carStockHouseId = ''
        this.formField.saleOrderDCode = ''
        this.formField.customerType = ''
        this.formField.customerName = ''
        this.formField.beginDate = ''
        this.formField.endDate = ''
        this.formField.saleType = ''
        this.formField.invoiceStatus = ''
      } else {
        this.formField.saleOrderDCode = ''
        this.formField.customerType = ''
        this.formField.customerName = ''
        this.formField.beginDate = ''
        this.formField.endDate = ''
        this.formField.saleType = ''
        this.formField.invoiceStatus = ''
      }
      this.tableComponents.find(o=>o.labelName==="制单日期：").compKey=this.tableComponents.find(o=>o.labelName==="制单日期：").compKey+"1"
    },
    exportExcel1(){
      //导出
      exportExcel(this.formField, orgApis.getSparePartsExtele.APIUrl, orgApis.getSparePartsExtele.ServiceCode, '网点销售开票信息查询')
    }
  },
  mounted() {
    if(this.$store.getters.orgInfo.DLR_ID === "HOST"){//总部
    } else {
      this.formField.moveState = this.$store.getters.orgInfo.USER_NAME
      this.formField.carStockHouseId = this.$store.getters.orgInfo.DLR_NAME
      this.tableComponents.find(o=>o.codeField==='moveState').disabled = true
      this.tableComponents.find(o=>o.codeField==='carStockHouseId').disabled = true
    }
    this.$refs.multipleTable.list = [
      {
        index: 1,
      },
    ];
  },
};
</script>

<style>
</style>
